import java.util.Scanner;

public class HJ2 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()){
            // 获取第一行数据
            String s = scanner.nextLine().toLowerCase();
            // 获取第二行数据的第一个字符
            Character c = scanner.next().toLowerCase().charAt(0);
            String first  = String.valueOf(c);
            int n = 0;
            for (int i = 0 ;i<s.length();i++) {
                if (String.valueOf(s.charAt(i)).equals(first)){
                    n++;
                }
            }
            System.out.println(n);
        }

    }
}
